package com.dao;

import com.bean.*;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2016/12/23.
 */
@Service
public class PaperDao {
    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;
    //指导老师制定论文题目
    public void insertPaperTitle(Paper paper){
        sqlSessionTemplate.insert("insertPaperTitle",paper);
    }

    public void updatePaperTeacherId(PaperChoice paperChoice){
        sqlSessionTemplate.update("com.dao.PaperMapper.updatePaperTeacherId",paperChoice);
    }
    public List<Paper> getPaperByTeacher(Long id){
        return sqlSessionTemplate.selectList("com.dao.PaperMapper.getPaperByTeacher",id);
    }
    public List<Paper> getPaperById(Long id){
        return sqlSessionTemplate.selectList("com.dao.PaperMapper.getPaperById",id);
    }
    public void updatePaperTitleById(Paper paper){
        sqlSessionTemplate.update("com.dao.PaperMapper.updatePaperTitleById",paper);
    }
    public void delPaperById(Long id){
        sqlSessionTemplate.delete("com.dao.PaperMapper.delPaperById",id);
    }
    public List<Paper> getOptionalPaperTitle(Long teacherid){
        return sqlSessionTemplate.selectList("com.dao.PaperMapper.getOptionalPaperTitle",teacherid);
    }
    public List<PaperCustom> getStudentPaperChoice(Long studentId){
        return sqlSessionTemplate.selectList("com.dao.PaperCustomMapper.getStudentPaperChoice",studentId);
    }
    public void insertPaperTitleByStudent(Paper paper){
        sqlSessionTemplate.insert("com.dao.PaperMapper.insertPaperTitleByStudent",paper);
    }
    public void updatePaperTitleByStudent(PaperCustom paperCustom){
        sqlSessionTemplate.update("com.mapper.PaperChoiceMapper.updatePaperTitleByStudent",paperCustom);
    }
    public List<PaperChoice> getTeacherIdByStudent(Long studentid){
        return sqlSessionTemplate.selectList("com.mapper.PaperChoiceMapper.getTeacherIdByStudent",studentid);
    }
    public void delPaperTitleByStudent(Long studentId){
        sqlSessionTemplate.update("com.mapper.PaperChoiceMapper.delPaperTitleByStudent",studentId);
    }
    public void updatePaperTitle(PaperChoice paperChoice){
        sqlSessionTemplate.update("com.mapper.PaperChoiceMapper.updatePaperTitle",paperChoice);
    }
    public void updateReviewAndGrade(PaperChoice paperChoice){
        sqlSessionTemplate.update("com.mapper.PaperChoiceMapper.updateReviewAndGrade",paperChoice);
    }
    public void updatePaperReview(Paper paper){
        sqlSessionTemplate.update("com.dao.PaperMapper.updatePaperReview",paper);
    }
    public List<PaperChoice> getTitleId(Long paperchoiceid){
        return sqlSessionTemplate.selectList("com.mapper.PaperChoiceMapper.getTitleId",paperchoiceid);
    }
    public void insertStudentIdAndTeacherId(PaperChoice paperChoice){
        sqlSessionTemplate.insert("com.mapper.PaperChoiceMapper.insertStudentIdAndTeacherId",paperChoice);
    }
    public List<Student> getStudentByChoiceId(Long choiceid){
        return sqlSessionTemplate.selectList("com.dao.StudentMapper.getStudentByChoiceId",choiceid);
    }
    public void updatePaperTeacherByStudent(PaperCustom paperCustom){
        sqlSessionTemplate.update("com.mapper.PaperChoiceMapper.updatePaperTeacherByStudent",paperCustom);
    }
    public Long getChoicedPaper(Long studentId){
        return sqlSessionTemplate.selectOne("com.mapper.PaperChoiceMapper.getChoicedPaper",studentId);
    }
    public List<Paper> getAllPaperTitle(Long studentId){
        return sqlSessionTemplate.selectList("com.dao.PaperMapper.getAllPaperTitle",studentId);
    }
    public List<Paper> getTitleByStudentId(Long studentId){
        return sqlSessionTemplate.selectList("com.dao.PaperMapper.getTitleByStudentId",studentId);
    }
    public void updatePaper(Paper paper){
        sqlSessionTemplate.update("com.dao.PaperMapper.updatePaper",paper);
    }
    public List<PaperChoice> getTitleIdByStudentId(Long studentId){
        return sqlSessionTemplate.selectList("com.mapper.PaperChoiceMapper.getTitleIdByStudentId",studentId);
    }
    public List<Paper> getPaperByStudentId(Long studentId){
        return sqlSessionTemplate.selectList("com.dao.PaperMapper.getPaperByStudentId",studentId);
    }
}
